\subsection{Implementation}

\subsubsection{Implementation Overview}
Conceptually, our web service offers two main functionalities:

\begin{itemize}

\item setWeatherStatus: The user uploads weather information about his  current location. This information is stored in the server and used  later in order to create a more accurate localized weather forecast.


\item getProposals: The user sends his current location and gets a list of interesting venues depending on the current weather in his area.

\end{itemize}

For each of the above mentioned functionalities we have implemented two methods that differ only in the parameters that they get as input:

\begin{itemize}

\item MethodName...ByAddress: The user defines his current location by   providing a string that represents his address. The address string   must consist of four parts that are separated by a comma like in the   following example: "Street Name and Number, Postal Code, City, Country". Note that not all fields need to be non-empty. For example "Street Name and Number, , City, Country" is also a valid address string.

\item MethodName...ByCoordinates: The user defines his current location
  by providing his GPS coordinates (longitude and latitude).

\end{itemize}

Summing up, our web service exposes 4 methods that can be used by its clients. These are the following:

\begin{itemize}

\item setWeatherStatusByAddress (String stype, String location)
\item setWeatherStatusByCoordinates (String stype, double longtitude, double latitude)
\item getProposalsByAddress (String location)
\item getProposalsByCoordinates (double longtitude, double latitude)

\end{itemize}

All of the above methods return an object of the type ResponseMessage. More details about the structure and usage of this object can be found at the documentation that is included in our source code files.

\subsubsection{Implementation Details}

This section provides a detailed description of the internal logic of our web service.

\textbf{getProposals}

The first steps are different between the two variants:

\textit{...byAddress}

\begin{enumerate}

\item Convert the location string to a Location object
\item Convert the initial Location object that didn't have any coordinates to a list of matching Location objects that contain coordinates and are returned by the geolocation web service that we use

\end{enumerate}

\textit{...ByCoordinates}

\begin{enumerate}

\item Convert the location coordinates to a Location object
\item Convert the initial Location object that didn't have any address to a list of matching Location objects that contain the corresponding addresses and are returned by the inverse geolocation web service that we use

\end{enumerate}

The next steps are common in the implementation of both variants:

\begin{enumerate}
\setcounter{enumi}{2}

\item If the list is empty return an error code (-1)
\item If the list contains more than one Location objects we return an error code (-2) along with a list of possible addresses as a suggestion to the user
\item If the list contains only one Location object we:

\begin{enumerate}

  \item Get the official weather status (as reported by the web service that we have chosen)
  \item Get the unofficial weather status (as reported by the users).The variable votesInFavor represents the number of users that have submitted the "winning" weather status within our radius. The variable totalVotes represents the total number of users that have uploaded a weather report within our radius.
  \item Calculate the weighted average of the official and the reported weather status and decide which type of weather is prevalent in the area
  \item Get proposals for interesting venues in the area depending on the previously calculated weather status. The mapping between weather statuses and interesting activities is represented in the following list:

    \begin{itemize}

    \item[-] Clear  \rightarrow Tennis
    \item[-] Clouds \rightarrow Cinema
    \item[-] Rain   \rightarrow Museum
    \item[-] Snow   \rightarrow Bowling
    \item[-] Storm  \rightarrow Hotel

    \end{itemize}

\end{enumerate}
\end{enumerate}

\textbf{setWeatherStatus}

The first step is common in the implementation of both variants:

\begin{enumerate}

\item Convert the weather type from string to integer

\end{enumerate}

The next two steps are different between the two variants:

\textit{...byAddress}

\begin{enumerate}
\setcounter{enumi}{1}

\item Convert the location string to a Location object
\item Convert the initial Location object that didn't have any coordinates to a list of matching Location objects that contain coordinates and are returned by the geolocation web service that we use

\end{enumerate}

\textit{...ByCoordinates}

\begin{enumerate}
\setcounter{enumi}{1}

\item Convert the location coordinates to a Location object
\item onvert the initial Location object that didn't have any address to a list of matching Location objects that contain the corresponding addresses and are returned by the inverse geolocation web service that we use

\end{enumerate}

The final steps are common in the implementation of both variants:

\begin{enumerate}
\setcounter{enumi}{3}

\item If the list is empty return an error code (-1)
\item If the list contains more than one Location objects we do not save the weather status and return an error code (-2) along with a list of possible addresses as a suggestion to the user
\item If the list contains only one Location object, we save the weather status for this location and return a success code

\end{enumerate}